<?php
	if(!defined("IN_APP"))
	{
		exit;
	}
	
	if(!adminpermission('N','100000'))
	{
		echo '无权查看!';
		exit;
	}
	
	$method = getParam('m','get','list');
	
	$parm = requestArrayParm($_REQUEST);
	
	$fTitle = "内容管理";
	$sTitle = "Banner管理";
	
	if($method == 'app')
	{
		$search = array();
		
		$search['type'] = 'app';
		
		$search['status'] = array('in','1,2');
		
		$page = $pages['page'] = getParam('page','request','1');
		
		$pages['rows'] = 20;
		
		$resData = _SqlTool::getOplogList('banner', $search, $pages,array() ,$between);
		
		//查询对应的数据
		
		foreach ($resData['list']  as $key => $value)
		{
			$list[] = $value;
		}
		
		$pageurl = SITE_URL.'index.php?'.set_URL_Param(get_URL_Param());
	
		$pagetotal = $resData["pages"];
		
		include renderTemplate('guanggao/app');
	}
	
	if($method == 'touch')
	{
		$search = array();
		
		$search['type'] = 'touch';
		
		$search['status'] = array('in','1,2');
		
		$page = $pages['page'] = getParam('page','request','1');
		
		$pages['rows'] = 20;
		
		$resData = _SqlTool::getOplogList('banner', $search, $pages,array() ,$between);
		
		//查询对应的数据
		
		foreach ($resData['list']  as $key => $value)
		{
			$list[] = $value;
		}
		
		$pageurl = SITE_URL.'index.php?'.set_URL_Param(get_URL_Param());
	
		$pagetotal = $resData["pages"];
		
		include renderTemplate('guanggao/touch');
	}	
	
	if($method == 'pc')
	{
		$search = array();
		
		$search['type'] = 'pc';
		
		$search['status'] = array('in','1,2');
		
		$page = $pages['page'] = getParam('page','request','1');
		
		$pages['rows'] = 20;
		
		$resData = _SqlTool::getOplogList('banner', $search, $pages,array() ,$between);
		
		//查询对应的数据
		
		foreach ($resData['list']  as $key => $value)
		{
			$list[] = $value;
		}
		
		$pageurl = SITE_URL.'index.php?'.set_URL_Param(get_URL_Param());
	
		$pagetotal = $resData["pages"];
		
		include renderTemplate('guanggao/pc');
	}
	
	if($method == 'edit')
	{
		if($parm['id'])
		{
			unset($where,$data);
			$wheres['id'] = $parm['id'];
			$guanggao = _SqlTool::getInfo('banner', $wheres);

			if(empty($guanggao))
			{
				header("Location:".SITE_URL.'index.php?a=guanggaoM&m='+$parm['type']);
			}
			if($guanggao['type'] == 'pc')
			{
				$pagetitle = "编辑Pc信息";
				$type = 'Pc';
			}
			
			if($guanggao['type'] == 'app')
			{
				$pagetitle = "编辑App信息";
				$type = 'App';
			}
			
			if($guanggao['type'] == 'touch')
			{
				$pagetitle = "编辑Touch信息";
				$type = 'Touch';
			}
			
			$parm['type'] = $guanggao['type'];
		}
		else
		{
			header("Location:".SITE_URL.'index.php?a=guanggaoM&m='+$parm['type']);
		}
		
		include renderTemplate('guanggao/info');
	}
	
	if($method == 'add')
	{
		if($parm['type'] == 'pc')
		{
			$pagetitle = "添加Pc信息";
			$type = 'Pc';
		}
		
		if($parm['type'] == 'app')
		{
			$pagetitle = "添加App信息";
			$type = 'App';
		}
		
		if($parm['type'] == 'touch')
		{
			$pagetitle = "添加Touch信息";
			$type = 'Touch';
		}
		
		
		include renderTemplate('guanggao/info');
	}
